package com.sunreal.paygateway.Interceptors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.sunreal.paygateway.common.PayConstant;

/**
 * 功能描述：拦截器配置
 *
 * @Author 彭广
 * @Date 2019/1/18
 */
@Configuration
public class IntercepterConfig implements WebMvcConfigurer {
    @Autowired
    private ParameterSignInterceptor parameterInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //针对对外接口，进行签名校验
        registry.addInterceptor(parameterInterceptor).addPathPatterns(PayConstant.INTERCEPTER_PATH);
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("forward:/index.html");
        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
    }
}
